package com.example.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * @author Jiange
 * @create 2021-05-28-14:10
 */
@Component
public class Produce {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    public void produceMeg(){
        jmsMessagingTemplate.convertAndSend(queue,"dasdsadsadsad");
    }

    @Scheduled(fixedDelay = 3000)
    public void produceMegScheduled(){
        jmsMessagingTemplate.convertAndSend(queue,"dasdsadsadsad");
    }
}
